package testDemo.Test7;

import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        //字节流复制文档内容
//        File a = new File("a.txt");
//        File b = new File("b.txt");
//        InputStream bis = new FileInputStream(a);
//        OutputStream bos = new FileOutputStream(b);
////        InputStream bis = new BufferedInputStream(new FileInputStream("a.txt"));
////        OutputStream bos=new BufferedOutputStream(new FileOutputStream("b.txt"));
//        byte[] buffer=new byte[1024];
//        int len=0;
//        while((len=bis.read(buffer))!=-1){
//            System.out.println(new String(buffer,0,len));
//            bos.write(buffer,0,len);
//        }
        //字节流复制图片
        InputStream bis = new BufferedInputStream(new FileInputStream("a.txt"));
        OutputStream bos = new BufferedOutputStream(new FileOutputStream("b.txt"));
                byte[] buffer=new byte[2];
        int len=0;
        while((len=bis.read(buffer))!=-1){
            System.out.println(new String(buffer,0,len));
            bos.write(buffer,0,len);
        }
        bis.close();
        bos.close();
    }
}
